From: Carlos Garnacho Date: Sun, 23 Jul 2017 11:51:11 +0000 (+0200) Subject: keyboard: Only rebuild keyboard actor on keyboard type changes X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~197 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=08ad345f234ae7af4798da9aa60c35f37208d02f;p=gnome-shell.git keyboard: Only rebuild keyboard actor on keyboard type changes About every other situation can do with synchronizing keyboard visibility, and keyboard layout changes are already handled internally in the Keyboard object. A downside of this approach is that once created, there will always be a Keyboard instance and its full actor hierarchy. Seems reasonable to do that since we can't tell it won't ever be needed. https://bugzilla.gnome.org/show_bug.cgi?id=785309 --- diff --git a/js/ui/keyboard.js b/js/ui/keyboard.js index a0732f5b5..da36c3615 100644 --- a/js/ui/keyboard.js +++ b/js/ui/keyboard.js @@ -171,7 +171,7 @@ var Keyboard = new Lang.Class({ this._keyboardSettings = new Gio.Settings({ schema_id: KEYBOARD_SCHEMA }); this._keyboardSettings.connect('changed', Lang.bind(this, this._sync)); this._a11yApplicationsSettings = new Gio.Settings({ schema_id: A11Y_APPLICATIONS_SCHEMA }); - this._a11yApplicationsSettings.connect('changed', Lang.bind(this, this._sync)); + this._a11yApplicationsSettings.connect('changed', Lang.bind(this, this._syncEnabled)); this._lastDeviceId = null; Caribou.DisplayAdapter.set_default(new LocalAdapter()); @@ -183,7 +183,7 @@ var Keyboard = new Lang.Class({ if (device.get_device_name().indexOf('XTEST') < 0) { this._lastDeviceId = deviceId; - this._sync(); + this._syncEnabled(); } })); this._sync(); @@ -304,24 +304,32 @@ var Keyboard = new Lang.Class({ return device.get_device_type() == Clutter.InputDeviceType.TOUCHSCREEN_DEVICE; }, - _sync: function () { + _syncEnabled: function () { this._enableKeyboard = this._a11yApplicationsSettings.get_boolean(SHOW_KEYBOARD) || this._lastDeviceIsTouchscreen(); if (!this._enableKeyboard && !this._keyboard) return; - if (this._enableKeyboard && this._keyboard && - this._keyboard.keyboard_type == this._keyboardSettings.get_string(KEYBOARD_TYPE)) - return; this._setCaretTrackerEnabled(this._enableKeyboard); - if (this._keyboard) - this._destroyKeyboard(); + if (this._enableKeyboard) { + if (!this._keyboard) + this._setupKeyboard(); + else + Main.layoutManager.showKeyboard(); + } else { + Main.layoutManager.hideKeyboard(true); + } + }, - if (this._enableKeyboard) + _sync: function () { + if (this._keyboard && + this._keyboard.keyboard_type != this._keyboardSettings.get_string(KEYBOARD_TYPE)) { + this._destroyKeyboard(); this._setupKeyboard(); - else - Main.layoutManager.hideKeyboard(true); + } + + this._syncEnabled(); }, _destroyKeyboard: function() {